<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>V-FOR</title>
</head>
<body>
    <div id="app">
        <input type="button" value="add" @click="add">
        <input type="button" value="remove" @click="remove">
        <ul>
            <li v-for="(city,index) in arr">{{index+1}}-广东城市:{{city}}</li>
        </ul>
        <h2 v-for="item in foods" v-bind:title="item.name">
            {{item.name}}
        </h2>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                arr:["广州","深圳","东莞"],
                foods:[
                    {name:"苹果"},
                    {name:"雪梨"},
                    {name:"香蕉"}
                ]
            },
            methods: {
                add:function(){
                    this.foods.push({name:"西瓜"})
                },
                remove:function(){
                    this.foods.shift();
                }
            }
        })
    </script>
</body>
</html>